package com.xijia.example.manage.all.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import org.springframework.stereotype.Service;
import io.github.wslxm.springbootplus2.core.base.model.BasePage;
import io.github.wslxm.springbootplus2.core.constant.SymbolConst;
import io.github.wslxm.springbootplus2.core.base.service.impl.BaseServiceImpl;
import io.github.wslxm.springbootplus2.core.utils.XjBeanUtil;
import com.xijia.example.manage.all.mapper.SiteCheckLogMapper;
import com.xijia.example.manage.all.service.SiteCheckLogService;
import com.xijia.example.manage.all.model.entity.SiteCheckLog;
import com.xijia.example.manage.all.model.vo.SiteCheckLogVO;
import com.xijia.example.manage.all.model.dto.SiteCheckLogDTO;
import com.xijia.example.manage.all.model.query.SiteCheckLogQuery;
import org.apache.commons.lang3.StringUtils;
import java.util.List;

/**
 * 站点监控 ServiceImpl
 *
 * <p>
 * ::本代码由[兮家小二]提供的代码生成器生成,如有问题,请手动修改 ::作者CSDN:https://blog.csdn.net/qq_41463655
 * </p>

 * @author ws
 * @email 1720696548@qq.com
 * @date 2024-09-25 13:34:24
 */
@Service
public class SiteCheckLogServiceImpl extends BaseServiceImpl<SiteCheckLogMapper, SiteCheckLog> implements SiteCheckLogService {

    @Override
    public BasePage<SiteCheckLogVO> findPage(SiteCheckLogQuery query) {
        LambdaQueryWrapper<SiteCheckLog> queryWrapper = new LambdaQueryWrapper<SiteCheckLog>().orderByDesc(SiteCheckLog::getCreateTime);
        queryWrapper.likeRight(StringUtils.isNotBlank(query.getSiteId()), SiteCheckLog::getSiteId, query.getSiteId());
        queryWrapper.likeRight(StringUtils.isNotBlank(query.getSite()), SiteCheckLog::getSite, query.getSite());
        queryWrapper.likeRight(StringUtils.isNotBlank(query.getType()), SiteCheckLog::getType, query.getType());
        queryWrapper.likeRight(StringUtils.isNotBlank(query.getState()), SiteCheckLog::getState, query.getState());
        Page<SiteCheckLog> page = this.page(new Page<>(query.getCurrent(), query.getSize()), queryWrapper);
        return XjBeanUtil.pageVo(page, SiteCheckLogVO.class);
    }

    @Override
    public SiteCheckLogVO findId(String id) {
        return XjBeanUtil.convert(this.getById(id), SiteCheckLogVO.class);
    }

    @Override
    public String insert(SiteCheckLogDTO dto) {
        SiteCheckLog entity = dto.convert(SiteCheckLog.class);
        boolean b = this.save(entity);
        return entity.getId();
    }

    @Override
    public boolean upd(String id, SiteCheckLogDTO dto) {
        SiteCheckLog entity = dto.convert(SiteCheckLog.class);
        entity.setId(id);
        return this.updateById(entity);
    }

    @Override
    public boolean del(String id) {
        return this.removeById(id);
    }

}
